<?php

/**
 * TeacherTitle table data gateway
 *
 * @version $Id: TeacherTitle.php 73 2010-04-25 00:30:44Z yingkuang.chen@gmail.com $
 * @license New BSD License
 * @uses Zend_Db_Table_Abstract
 * @package teacher
 * @subpackage Model
 */
class Teacher_Model_DbTable_TeacherTitle extends Zend_Db_Table_Abstract
{

	protected $_name = 'teacher_title';
	protected $_primary = 'sn';



	public function  get_title_kind() {
		$locale = Bootstrap::$config['resources']['locale']['default'];
		$path = dirname(__FILE__)."/../../languages/$locale/data.ini";
		$ini = new Zend_Config_Ini($path);
		$data = $ini->get('array_data')->toArray();
		return $data['current_kind_sn'];
	}



	public function getParentCount()
	{

		$select = $this->getAdapter()->select()
		->from(array('t'=>'teacher_title'),
		array('t.division_sn','cc'=>'COUNT(*)'))
		->join(array('r'=>'school_room'),
		't.division_sn=r.sn',array())
		->group('t.division_sn');
		//echo $select;exit;
		$res = $this->getAdapter()->query($select)->fetchAll();
		$arr = array();
		foreach($res as $row) {
			$arr[$row['division_sn']] = $row['cc'];
		}
		return $arr;
	}

	public function getMultiOptions()
	{
		$select = $this->select();
		$select->from('teacher_title',array('sn','name_short'));
		return $this->getAdapter()->fetchPairs($select);
	}
}